package org.example.jdbc.controller;

import org.example.jdbc.entity.Info;
import org.example.jdbc.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/info")
public class InfoController {
    @Autowired
    private InfoService infoService;

    @GetMapping
    public List<Info> getAll(){
        return infoService.getAll();
    }

    @GetMapping("/{id}")
    public Info get(@PathVariable Integer id){
        return infoService.get(id);
    }

    @PostMapping
    public int add(@RequestBody Info info){
        return infoService.add(info);
    }

    @DeleteMapping("/{id}")
    public int del(@PathVariable Integer id){
        return infoService.del(id);
    }

    @PutMapping
    public int update(@RequestBody Info info){
        return infoService.update(info);
    }
}
